package dsl.test

import java.lang.management.ManagementFactory

import groovy.json.JsonSlurper

class JsonTest {

	static void main(String[] args) {
		jsonSlurperMapTest()
		jsonSlurperListTest()

		def os = ManagementFactory.operatingSystemMXBean
		println """OPERATING SYSTEM:
				\tarchitecture = $os.arch
				\tname = $os.name
				\tversion = $os.version
				\tprocessors = $os.availableProcessors
				"""
	}

	static def jsonSlurperMapTest() {
		def jsonSlurper = new JsonSlurper()
		def object = jsonSlurper.parseText('{ "name": "John Doe" } /* some comment */')

		assert object instanceof Map
		assert object.name == 'John Doe'
	}

	static def jsonSlurperListTest()  {
		def jsonSlurper = new JsonSlurper()
		def object = jsonSlurper.parseText('{ "myList": [4, 8, 15, 16, 23, 42] }')

		assert object instanceof Map
		assert object.myList instanceof List
		assert object.myList == [4, 8, 15, 16, 23, 42]
	}
}
